<?php
namespace App\Libraries\classs\red;
/**
 * Created by PhpStorm.
 * User: costa92
 * Date: 2016/12/19
 * Time: 下午4:54
 */
use EasyWeChat\Foundation\Application;
class Send
{
    private $_app;
    protected $_luckyMoney;
    public function __construct()
    {
        $this->app();
        $this->sendRed();
    }

    static $instance;
    public static function  getInstance(){
        if( self::$instance==null ){
            self::$instance = new self();
        }
        return self::$instance;
    }

    protected function app(){
        $this->_app = new Application(config('wechat'));
    }

    /**
     * 实例化easywechat
     */
    protected function sendRed(){
        $this->_luckyMoney=$luckyMoney=$this->_app->lucky_money;
    }

    public function sendNormal($luckyMoneyData){
        $luckyMoneyData['mch_billno'] =$this->_app->config->payment['merchant_id'].date('YmdHis').rand(1000, 9999);
        return object2array($this->_luckyMoney->sendNormal($luckyMoneyData));
    }
}